﻿Imports System.Data.OleDb

Public Class CategoriesDAO
    Public Function Categories_List() As DataSet
        Return objConnectionDAO.ExecuteStoreprocedure("spTDT_Categories_List", Nothing)
    End Function

    Public Function Categories_Delete(ByVal CategoryID As Integer) As Boolean
        Dim para(1) As OleDbParameter

        para(0) = New OleDbParameter("@CategoryID", CategoryID)
        para(0).OleDbType = OleDbType.Integer

        para(1) = New OleDbParameter("@Success", OleDbType.Boolean)
        para(1).Direction = ParameterDirection.Output

        objConnectionDAO.ExecuteStoreprocedureNoneReturn("spTDT_Categories_Delete", para)
        Return para(1).Value
    End Function

    Public Function Categories_Select(ByVal ItemID As Integer) As DataSet
        Dim para(0) As OleDbParameter
        para(0) = New OleDbParameter("@ItemID", ItemID)
        para(0).OleDbType = OleDbType.Integer

        Return objConnectionDAO.ExecuteStoreprocedure("spTDT_Categories_Select", para)
    End Function

    Public Function Categories_Insert(ByVal CategoryName As String, _
                                      ByVal Description As String, _
                                      ByVal ModifiedOn As Date, _
                                      ByVal ModifiedBy As String, _
                                      ByVal CreatedOn As Date, _
                                      ByVal CreatedBy As String, _
                                      ByVal RowDelete As Boolean) As Boolean
        Dim para(6) As OleDbParameter
        para(0) = New OleDbParameter("@CategoryName", CategoryName)
        para(0).OleDbType = OleDbType.VarWChar

        para(1) = New OleDbParameter("@Description", Description)
        para(1).OleDbType = OleDbType.VarWChar

        para(2) = New OleDbParameter("@ModifiedOn", ModifiedOn)
        para(2).OleDbType = OleDbType.Date

        para(3) = New OleDbParameter("@ModifiedBy", ModifiedBy)
        para(3).OleDbType = OleDbType.VarWChar

        para(4) = New OleDbParameter("@CreatedOn", CreatedOn)
        para(4).OleDbType = OleDbType.Date

        para(5) = New OleDbParameter("@CreatedBy", CreatedBy)
        para(5).OleDbType = OleDbType.VarWChar

        para(6) = New OleDbParameter("@RowDelete", RowDelete)
        para(6).OleDbType = OleDbType.Boolean

        Return objConnectionDAO.ExecuteStoreprocedureNoneReturn("spTDT_Categories_Insert", para)
    End Function

    Public Function Categories_Update(ByVal CategoryID As Integer, _
                                      ByVal CategoryName As String, _
                                      ByVal Description As String, _
                                      ByVal ModifiedOn As Date, _
                                      ByVal ModifiedBy As String, _
                                      ByVal CreatedOn As Date, _
                                      ByVal CreatedBy As String, _
                                      ByVal RowDelete As Boolean) As Boolean
        Dim para(7) As OleDbParameter
        para(0) = New OleDbParameter("@CategoryID", CategoryID)
        para(0).OleDbType = OleDbType.Integer

        para(1) = New OleDbParameter("@CategoryName", CategoryName)
        para(1).OleDbType = OleDbType.VarWChar

        para(2) = New OleDbParameter("@Description", Description)
        para(2).OleDbType = OleDbType.VarWChar

        para(3) = New OleDbParameter("@ModifiedOn", ModifiedOn)
        para(3).OleDbType = OleDbType.Date

        para(4) = New OleDbParameter("@ModifiedBy", ModifiedBy)
        para(4).OleDbType = OleDbType.VarWChar

        para(5) = New OleDbParameter("@CreatedOn", CreatedOn)
        para(5).OleDbType = OleDbType.Date

        para(6) = New OleDbParameter("@CreatedBy", CreatedBy)
        para(6).OleDbType = OleDbType.VarWChar

        para(7) = New OleDbParameter("@RowDelete", RowDelete)
        para(7).OleDbType = OleDbType.Boolean



        Return objConnectionDAO.ExecuteStoreprocedureNoneReturn("spTDT_Categories_Update", para)
    End Function

    'Public Function Categories_Delete(ByVal CategoryID As Integer) As Boolean
    '    Dim para(1) As OleDbParameter
    '    para(0) = New OleDbParameter("@CategoryID", CategoryID)
    '    para(0).OleDbType = OleDbType.Integer

    '    para(1) = New OleDbParameter("@Success", OleDbType.Boolean)
    '    para(1).Direction = ParameterDirection.Output

    '    objConnectionDAO.ExecuteStoreprocedureNoneReturn("spTDT_Categories_Delete", para)
    '    Return para(1).Value
    'End Function



End Class
